local charactername = "doro"
local uppername = string.upper(charactername)
--STRINGS.INFO_WHAT
STRINGS.INFO_DORO = {
    --STRINGS.INFO_WHAT.ACTIONS
    ACTIONS = {
        DORO_SWITCH_WEAPON = "切换 影",
        DORO_SWITCH_WEAPON_FN = function(act)
            local target = act.invobject or act.target
            if target and target:HasTag("doro_weapon_shadow") then
                return "“切换 山 ”"
            else
                return "“切换 影 ”"
            end
        end,
    },
    --STRINGS.INFO_WHAT.DISH
    DISH = {
    },
    ANNOUNCE = {
    },
    UI_STRING = {
    },
}

local msg = {
    doro = {
        name = "Doro",
        special_desc = "Doro",
        desc = "Doro",
        recipe_desc = "Doro",
    },
    doro_orange = {
        name = "哦润吉",
        special_desc = "吃多了不知道会不会变黄。",
        desc = "吃多了不知道会不会变黄。",
        recipe_desc = "哦润吉",
    },
    doro_orange_bush = {
        name = "哦润吉丛",
        special_desc = "doro的最爱",
        desc = "doro的最爱",
        recipe_desc = "无穷无尽的哦润吉",
    },
    doro_orange_bush_item = {
        name = "哦润吉丛",
        special_desc = "这是上天赐予doro的礼物！",
        desc = "这是上天赐予doro的礼物！",
        recipe_desc = "无穷无尽的哦润吉",
    },
    doro_orange_hat = {
        name = "哦润吉果篮",
        special_desc = "老板要买哦润吉嘛～",
        desc = "老板要买哦润吉嘛～",
        recipe_desc = "超多哦润吉（流口水）",
    },
    doro_orange_pie= {
        name = "哦润吉派",
        special_desc = "哦润吉派！",
        desc = "哦润吉派！",
        recipe_desc = "哦润吉派",
    },
    doro_orange_sugar= {
        name = "哦润吉糖果",
        special_desc = "是糖果太好了！",
        desc = "是糖果太好了！",
        recipe_desc = "哦润吉糖果",
    },
    doro_weapon_shadow = {
        name = "doro之剑",
        desc = "用了很多欧润吉换来的",
        recipe_desc = "doro之剑",
    },
    doro_weapon_mountain = {
        name = "doro之剑",
        desc = "用了很多欧润吉换来的",
        recipe_desc = "doro之剑",
    },
    doro_fly_sword = {
        name = "doro之剑",
        desc = "用了很多欧润吉换来的",
        recipe_desc = "doro之剑",
    },
}
STRINGS.CHARACTERS[uppername] = STRINGS.CHARACTERS[uppername] or {}
STRINGS.CHARACTERS[uppername].DESCRIBE = STRINGS.CHARACTERS[uppername].DESCRIBE or {}
for k, v in pairs(msg) do
    if v.name then
        STRINGS.NAMES[string.upper(k)] = v.name
    end
    if v.desc then
        if v.status then
            STRINGS.CHARACTERS.GENERIC.DESCRIBE[string.upper(k)] =
                STRINGS.CHARACTERS.GENERIC.DESCRIBE[string.upper(k)] or {}
            STRINGS.CHARACTERS.GENERIC.DESCRIBE[string.upper(k)].GENERIC = v.desc
        else
            STRINGS.CHARACTERS.GENERIC.DESCRIBE[string.upper(k)] = v.desc
        end
    end
    if v.special_desc then
        if v.status then
            STRINGS.CHARACTERS[uppername].DESCRIBE[string.upper(k)] =
                STRINGS.CHARACTERS[uppername].DESCRIBE[string.upper(k)] or {}
            STRINGS.CHARACTERS[uppername].DESCRIBE[string.upper(k)].GENERIC = v.special_desc
        else
            STRINGS.CHARACTERS[uppername].DESCRIBE[string.upper(k)] = v.special_desc
        end
    end
    if v.recipe_desc then
        STRINGS.RECIPE_DESC[string.upper(k)] = v.recipe_desc
    end
    if v.status then
        for status, data in pairs(v.status) do
            for name, desc in pairs(data) do
                if STRINGS.CHARACTERS[string.upper(name)] then
                    STRINGS.CHARACTERS[string.upper(name)].DESCRIBE[string.upper(k)][string.upper(status)] = desc
                end
            end
        end
    end
end
--替换克雷的only used by 的话
local characternames = {
    "warly",
}
local function TraceWithStack(character, root, tab, path)
    local stack = { { tab, path } }
    while #stack > 0 do
        local curtbl, curpath = unpack(table.remove(stack))
        for k, v in pairs(curtbl) do
            if type(v) == "table" then
                table.insert(curpath, k)
                table.insert(stack, { v, { unpack(curpath) } })
                table.remove(curpath)
            else
                for k2, v2 in pairs(root) do
                    if k2 ~= curpath[1] then
                        local data = v2
                        for i = 2, #curpath do
                            data = data[curpath[i]]
                            if not data then break end
                        end
                        if type(data) == "table" then
                            if data[k] == "only_used_by_" .. string.lower(character) then
                                data[k] = v
                            end
                        end
                    end
                end
            end
        end
    end
end
for _, p in ipairs(characternames) do
    local character = string.upper(p)
    local tab = STRINGS
    local stack = { { tab } }
    while #stack > 0 do
        local curtbl = table.remove(stack)
        for k, v in pairs(curtbl) do
            if type(v) == "table" then
                if v[character] and type(v[character]) == "table" then
                    TraceWithStack(character, v, v[character], { character })
                else
                    table.insert(stack, v)
                end
            end
        end
    end
end
